

/********************************************************************
*								    *
*	程序名称：多功能播放器					    *
*	编译环境：ubuntu之arm-linux-gcc 以及SecureCRT 7.3 	    *
*	作者相关：Yml			                            *
*	最后修改：2021.02.21				            *	
*                                                                   *
*********************************************************************/


#include<stdio.h>
#include<stdlib.h>
#include<fcntl.h>
#include<linux/input.h>
#include<sys/types.h>
#include<sys/stat.h>
#include<string.h>
#include<unistd.h>
#include<dirent.h>
#include<sys/mman.h>
#include"fun.h"
#include"ziku.h"
#include <linux/fb.h>
#include <sys/ioctl.h>
#include<stdbool.h>


int main()
{

	//创建音乐链表 
	headm = create_emptydlist();

	//创建图片链表 
	headi = create_emptydlist();

	//创建视频链表 
	headv = create_emptydlist();
	//映射显存LCD
	int fb = open("/dev/fb0",O_RDWR);
	if(fb == -1){
		perror("open");
		return -1;
	}	
	
	//建立映射关系
	int *memp =  (int *)mmap(NULL,800*480*4,PROT_WRITE|PROT_READ,MAP_SHARED,fb,0);
	
	if(memp == MAP_FAILED){
		perror("mmap");
		return -1;
	}

	//打开触摸屏

	int fdc = open("/dev/input/event0",O_RDWR);
	if(fdc == -1){
		perror("open");
		return -1;
	}

	//汉字库相关使用 
	if(ioctl(fb,FBIOGET_VSCREENINFO,&var)){
		printf("can't get var \n");
		return -1;
	}	
 
	if(ioctl(fb,FBIOGET_FSCREENINFO,&fix)){
		printf("can't get fix \n");
		return -1;
	}

	line_width = var.xres * var.bits_per_pixel / 8;
	pixel_width = var.bits_per_pixel/8;
	screen_size = var.xres * var.yres * var.bits_per_pixel / 8;

	fbmem = (unsigned char *)mmap(NULL,screen_size,PROT_READ | PROT_WRITE ,MAP_SHARED,fb,0);
	if(fbmem == (unsigned char *)-1){
		printf("can't mmap fbmem\n");
		return -1;
	}
 
	fd_hzk16 = open("HZK16",O_RDONLY);
	if(fd_hzk16 < 0){
		printf("can't open HZK16 \n");
		return -1;
	}
 
	if(fstat(fd_hzk16,&hzk_stat)){
		printf("can't get HZK16 \n");
		return -1;
	}
	
	
	hzkmem = (unsigned char *)mmap(NULL,hzk_stat.st_size,PROT_READ ,MAP_SHARED,fd_hzk16,0);
	if(hzkmem == (unsigned char *)-1){
		printf("can't mmap hzkmem\n");
		return -1;
	}

	//调用登录操作 
	login_image(memp,fdc,evt);

	munmap(memp,800*480*4);
	close(fb);
	close(fdc);

	return 0;
}


